#include "widget.h"

#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
}

Widget::~Widget()
{
}

void Widget::mousePressEvent(QMouseEvent *event)
{
    qDebug() << "鼠标按压事件被执行了";
}

bool Widget::event(QEvent *event)
{
    if(event->type() == QEvent::MouseButtonPress)
    {
        qDebug() << "在event函数中提前处理鼠标按压事件";
        return true;
    }

    return QWidget::event(event);
}

void Widget::keyPressEvent(QKeyEvent *event)
{
    qDebug() << "key----键盘按压事件被执行了";
}

